/*
 * Title: WADS
 * Description: Web-based Auto flow Documents System
 * Copyright: 2007
 * Company: CoE
 * @author: Mr.Nattasan Wang-Aphisit
 * @version 1.1
 */

package wads.com;

import java.io.Serializable;
import java.util.Vector;

final public class UserInfo implements Serializable{
//  private static final long serialVersionUID = -5208302488653404762L;
  
  private Vector<UserInfoDataStruct> data;

  public UserInfo() {
    data = new Vector<UserInfoDataStruct>();
  }
  
  public int getSize(){
    return data.size();
  }

  public void addData(UserInfoDataStruct user_data){
    data.add(user_data);
  }

  public void deleteData(int index){
    data.removeElementAt(index);
  }

  public void updateData(UserInfoDataStruct text, int index){
    data.setElementAt(text, index);
  }

  public UserInfoDataStruct getUserDataAt(int index){
    return data.elementAt(index);
  }

  public boolean isEmpty(){
    return data.isEmpty();
  }

  public UserInfoDataStruct getDataByUsername(String username) {
      for(int i=0;i<data.size();i++) {
          if(data.get(i).getUsername().equals(username)) {
              return data.get(i);
          }
      }

      return null;
  }

  /*public Object getUserDataAttribute(UserInfoDataStruct user_data, int attribute_index){
    return temp;
  }*/

  @Override
  public String toString() {
      String text = "";
      UserInfoDataStruct user;
      for(int i=0;i<data.size();i++) {
          user = this.getUserDataAt(i);
          text = text+user.toString()+"\n\n";
      }
      return text;
  }
}